﻿// =================================================================== 
// 项目说明
//====================================================================
// 
// 文件： UR_REPORTTEMPLATE.cs
// 项目名称：


// 创建时间：2013/3/19
// 负责人：
// ===================================================================
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;
using CommonLib.Model;
using CommonLib.IDAL;


//注意：该文件自动生成，一般请不要手工修改。




namespace MSSQLDAL
{
    /// <summary>
    /// 数据层实例化接口类 .
    /// </summary>
    public partial class UR_REPORTTEMPLATEDAL : IUR_REPORTTEMPLATEDAL
    {
		
		 #region 变量声明（For update 和 Insert 时）
		// 声明静态变量 
		private const string PARA_TEMPLATE_ID =  "@TEMPLATE_ID";
		private const string PARA_REPORTTYPE_ID =  "@REPORTTYPE_ID";
		private const string PARA_TEMPLATE_NAME =  "@TEMPLATE_NAME";
		private const string PARA_FILE_CONTENT =  "@FILE_CONTENT";
		private const string PARA_TEMPLATE_FILE =  "@TEMPLATE_FILE";
		private const string PARA_TEMPLATE_TYPE =  "@TEMPLATE_TYPE";
		private const string PARA_REPLACE_OPTION =  "@REPLACE_OPTION";
		private const string PARA_USE_RANGE =  "@USE_RANGE";
		private const string PARA_TEMPLATE =  "@TEMPLATE";
		private const string PARA_SUB_SYSTEM =  "@SUB_SYSTEM";
		private const string PARA_CLASS1 =  "@CLASS1";
		private const string PARA_CLASS2 =  "@CLASS2";
		private const string PARA_CLASS3 =  "@CLASS3";
		private const string PARA_REMARK =  "@REMARK";

		private const string SQL_UPDATE = "UPDATE UR_REPORTTEMPLATE SET  TEMPLATE_ID= @TEMPLATE_ID, REPORTTYPE_ID= @REPORTTYPE_ID, TEMPLATE_NAME= @TEMPLATE_NAME, FILE_CONTENT= @FILE_CONTENT, TEMPLATE_FILE= @TEMPLATE_FILE, TEMPLATE_TYPE= @TEMPLATE_TYPE, REPLACE_OPTION= @REPLACE_OPTION, USE_RANGE= @USE_RANGE, TEMPLATE= @TEMPLATE, SUB_SYSTEM= @SUB_SYSTEM, CLASS1= @CLASS1, CLASS2= @CLASS2, CLASS3= @CLASS3, REMARK= @REMARK  WHERE TEMPLATE_ID = @TEMPLATE_ID ";
		private const string SQL_INSERT = "INSERT INTO UR_REPORTTEMPLATE(TEMPLATE_ID, REPORTTYPE_ID, TEMPLATE_NAME, FILE_CONTENT, TEMPLATE_FILE, TEMPLATE_TYPE, REPLACE_OPTION, USE_RANGE, TEMPLATE, SUB_SYSTEM, CLASS1, CLASS2, CLASS3, REMARK ) values ( @TEMPLATE_ID, @REPORTTYPE_ID, @TEMPLATE_NAME, @FILE_CONTENT, @TEMPLATE_FILE, @TEMPLATE_TYPE, @REPLACE_OPTION, @USE_RANGE, @TEMPLATE, @SUB_SYSTEM, @CLASS1, @CLASS2, @CLASS3, @REMARK ) ";
		#endregion
		
		// 查询数据的sql串




		private string TableString;
		
		#region 构造函数




		/// <summary>
		/// ??????
		/// </summary>
		public UR_REPORTTEMPLATEDAL()
		{
			if (QueryDataString == "")
                TableString = "UR_REPORTTEMPLATE SQL_A";
            else
                TableString = "(" + QueryDataString + ") SQL_A";
		}
		#endregion

        //-----------实例化接口函数-----------
		
		//------------增删改函数------------------- 
		
		#region Add 向数据库中插入一条新记录。




		/// <summary>
		/// 向数据库UR_REPORTTEMPLATE中插入一条新记录。




		/// </summary>
		/// <param name="_UR_REPORTTEMPLATEModel">UR_REPORTTEMPLATE??</param>
		/// <returns>影响的行数</returns>
		public int Add(CommonLib.Model.UR_REPORTTEMPLATE _UR_REPORTTEMPLATEModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_TEMPLATE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_REPORTTYPE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_TEMPLATE_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_FILE_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_FILE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_REPLACE_OPTION, SqlDbType.VarChar), 
				new SqlParameter(PARA_USE_RANGE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE, SqlDbType.Binary), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.SmallInt), 
				new SqlParameter(PARA_CLASS1, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS2, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS3, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar)
			};			
			
			 _param[0].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_ID;
			 _param[1].Value =  _UR_REPORTTEMPLATEModel.REPORTTYPE_ID;
			 _param[2].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_NAME;
			 _param[3].Value =  _UR_REPORTTEMPLATEModel.FILE_CONTENT;
			 _param[4].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_FILE;
			 _param[5].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_TYPE;
			 _param[6].Value =  _UR_REPORTTEMPLATEModel.REPLACE_OPTION;
			 _param[7].Value =  _UR_REPORTTEMPLATEModel.USE_RANGE;
			 _param[8].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE;
			 _param[9].Value =  _UR_REPORTTEMPLATEModel.SUB_SYSTEM;
			 _param[10].Value =  _UR_REPORTTEMPLATEModel.CLASS1;
			 _param[11].Value =  _UR_REPORTTEMPLATEModel.CLASS2;
			 _param[12].Value =  _UR_REPORTTEMPLATEModel.CLASS3;
			 _param[13].Value =  _UR_REPORTTEMPLATEModel.REMARK;

			
			//  返回
			return (int)SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, SQL_INSERT, _param);


		}
		#endregion
		
		#region Add 向数据库中插入一条新记录。带事务
		/// <summary>
		/// 向数据库UR_REPORTTEMPLATE中插入一条新记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="_UR_REPORTTEMPLATEModel">UR_REPORTTEMPLATE实体</param>
		/// <returns>影响的行数</returns>
		public int Add(DBTransaction dbTrans,CommonLib.Model.UR_REPORTTEMPLATE _UR_REPORTTEMPLATEModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_TEMPLATE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_REPORTTYPE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_TEMPLATE_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_FILE_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_FILE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_REPLACE_OPTION, SqlDbType.VarChar), 
				new SqlParameter(PARA_USE_RANGE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE, SqlDbType.Binary), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.SmallInt), 
				new SqlParameter(PARA_CLASS1, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS2, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS3, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar)
			};	
			
			 _param[0].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_ID;
			 _param[1].Value =  _UR_REPORTTEMPLATEModel.REPORTTYPE_ID;
			 _param[2].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_NAME;
			 _param[3].Value =  _UR_REPORTTEMPLATEModel.FILE_CONTENT;
			 _param[4].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_FILE;
			 _param[5].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_TYPE;
			 _param[6].Value =  _UR_REPORTTEMPLATEModel.REPLACE_OPTION;
			 _param[7].Value =  _UR_REPORTTEMPLATEModel.USE_RANGE;
			 _param[8].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE;
			 _param[9].Value =  _UR_REPORTTEMPLATEModel.SUB_SYSTEM;
			 _param[10].Value =  _UR_REPORTTEMPLATEModel.CLASS1;
			 _param[11].Value =  _UR_REPORTTEMPLATEModel.CLASS2;
			 _param[12].Value =  _UR_REPORTTEMPLATEModel.CLASS3;
			 _param[13].Value =  _UR_REPORTTEMPLATEModel.REMARK;

			
			//  返回
			return (int)SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, SQL_INSERT, _param);
		}
		#endregion
		
		#region	Update 向数据表更新一条记录。	
		/// <summary>
		/// 向数据表UR_REPORTTEMPLATE更新一条记录。




		/// </summary>
		/// <param name="_UR_REPORTTEMPLATEModel">_UR_REPORTTEMPLATEModel</param>
		/// <returns>影响的行数</returns>
		public int Update(CommonLib.Model.UR_REPORTTEMPLATE _UR_REPORTTEMPLATEModel)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter(PARA_TEMPLATE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_REPORTTYPE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_TEMPLATE_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_FILE_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_FILE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_REPLACE_OPTION, SqlDbType.VarChar), 
				new SqlParameter(PARA_USE_RANGE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE, SqlDbType.Binary), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.SmallInt), 
				new SqlParameter(PARA_CLASS1, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS2, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS3, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar)
			};	
			
			 _param[0].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_ID;
			 _param[1].Value =  _UR_REPORTTEMPLATEModel.REPORTTYPE_ID;
			 _param[2].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_NAME;
			 _param[3].Value =  _UR_REPORTTEMPLATEModel.FILE_CONTENT;
			 _param[4].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_FILE;
			 _param[5].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_TYPE;
			 _param[6].Value =  _UR_REPORTTEMPLATEModel.REPLACE_OPTION;
			 _param[7].Value =  _UR_REPORTTEMPLATEModel.USE_RANGE;
			 _param[8].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE;
			 _param[9].Value =  _UR_REPORTTEMPLATEModel.SUB_SYSTEM;
			 _param[10].Value =  _UR_REPORTTEMPLATEModel.CLASS1;
			 _param[11].Value =  _UR_REPORTTEMPLATEModel.CLASS2;
			 _param[12].Value =  _UR_REPORTTEMPLATEModel.CLASS3;
			 _param[13].Value =  _UR_REPORTTEMPLATEModel.REMARK;
			
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, SQL_UPDATE, _param);
		}
		#endregion
		
		#region	Update 向数据表更新一条记录。带事务	
		/// <summary>
		/// 向数据表UR_REPORTTEMPLATE更新一条记录。带事务
		/// </summary>
		/// <param name="sp">事务对象</param>
		/// <param name="_UR_REPORTTEMPLATEModel">_UR_REPORTTEMPLATEModel</param>
		/// <returns>影响的行数</returns>
		public int Update(DBTransaction dbTrans,CommonLib.Model.UR_REPORTTEMPLATE _UR_REPORTTEMPLATEModel)
		{
           // 声明参数数组并赋值




		    SqlParameter[] _param=
			{
				new SqlParameter(PARA_TEMPLATE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_REPORTTYPE_ID, SqlDbType.Int), 
				new SqlParameter(PARA_TEMPLATE_NAME, SqlDbType.VarChar), 
				new SqlParameter(PARA_FILE_CONTENT, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_FILE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE_TYPE, SqlDbType.Int), 
				new SqlParameter(PARA_REPLACE_OPTION, SqlDbType.VarChar), 
				new SqlParameter(PARA_USE_RANGE, SqlDbType.VarChar), 
				new SqlParameter(PARA_TEMPLATE, SqlDbType.Binary), 
				new SqlParameter(PARA_SUB_SYSTEM, SqlDbType.SmallInt), 
				new SqlParameter(PARA_CLASS1, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS2, SqlDbType.VarChar), 
				new SqlParameter(PARA_CLASS3, SqlDbType.VarChar), 
				new SqlParameter(PARA_REMARK, SqlDbType.VarChar)
			};		
			
			 _param[0].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_ID;
			 _param[1].Value =  _UR_REPORTTEMPLATEModel.REPORTTYPE_ID;
			 _param[2].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_NAME;
			 _param[3].Value =  _UR_REPORTTEMPLATEModel.FILE_CONTENT;
			 _param[4].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_FILE;
			 _param[5].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE_TYPE;
			 _param[6].Value =  _UR_REPORTTEMPLATEModel.REPLACE_OPTION;
			 _param[7].Value =  _UR_REPORTTEMPLATEModel.USE_RANGE;
			 _param[8].Value =  _UR_REPORTTEMPLATEModel.TEMPLATE;
			 _param[9].Value =  _UR_REPORTTEMPLATEModel.SUB_SYSTEM;
			 _param[10].Value =  _UR_REPORTTEMPLATEModel.CLASS1;
			 _param[11].Value =  _UR_REPORTTEMPLATEModel.CLASS2;
			 _param[12].Value =  _UR_REPORTTEMPLATEModel.CLASS3;
			 _param[13].Value =  _UR_REPORTTEMPLATEModel.REMARK;
			

			
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, SQL_UPDATE, _param);
		}
		#endregion
		
		#region	Delete 根据主键，删除数据表中的一条记录	
		/// <summary>
		/// 根据主键，删除数据表UR_REPORTTEMPLATE中的一条记录




		/// </summary>
	    /// <param name="tEMPLATE_ID">tEMPLATE_ID</param>
		/// <returns>影响的行数</returns>
		public int Delete(int tEMPLATE_ID)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@tEMPLATE_ID", SqlDbType.Int)
			};				
			_param[0].Value = tEMPLATE_ID;
			
			string sqlStr="delete from UR_REPORTTEMPLATE where  TEMPLATE_ID=@tEMPLATE_ID";
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, sqlStr, _param);;
		}
		#endregion
		
		#region	Delete 根据主键，删除数据表中的一条记录 带事务




		/// <summary>
		/// 根据主键，删除数据表UR_REPORTTEMPLATE中的一条记录 带事务




		/// <param name="sp">事务对象</param>
	    /// <param name="TEMPLATE_ID">tEMPLATE_ID</param>
		/// <returns>影响的行数</returns>
		public int Delete(DBTransaction dbTrans,int tEMPLATE_ID)
		{
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@tEMPLATE_ID", SqlDbType.Int)
			};				
			_param[0].Value = tEMPLATE_ID;

			string sqlStr="delete from UR_REPORTTEMPLATE where  TEMPLATE_ID=@tEMPLATE_ID";
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, sqlStr,_param);;

		}
		#endregion
		
		#region	DeleteFK 根据条件串，删除数据表中的N条记录	
		/// <summary>
		/// 根据条件串，删除数据表UR_REPORTTEMPLATE中的N条记录




		/// </summary>
	    /// <param name="sWhere">条件串</param>
		/// <returns>影响的行数</returns>
		public int DeleteFK(string sWhere)
		{
			string  sqlStr="delete from UR_REPORTTEMPLATE";
			if (sWhere.Length>0)
				sqlStr += " where "+sWhere;
			return SqlHelper.ExecuteNonQuery(Conn.SqlConnStr, CommandType.Text, sqlStr);
		}
		#endregion
		
		#region	DeleteFK 删除数据表中的一条记录,带事务	
		/// <summary>
		/// 删除数据表UR_REPORTTEMPLATE中的一条记录,带事务




		/// </summary>
		/// <param name="sp">事务对象</param>
	    /// <param name="sWhere">条件串</param>
		/// <returns>影响的行数</returns>
		public int DeleteFK(DBTransaction dbTrans,string sWhere)
		{
			string  sqlStr="delete from UR_REPORTTEMPLATE";
			if (sWhere.Length>0)
				sqlStr += " where "+sWhere;
			return SqlHelper.ExecuteNonQuery(dbTrans.sql_trans, CommandType.Text, sqlStr);
		}
		
		#endregion
		
		
		//------------获取数据及模型函数




		
		#region Exists 检测是否存在该主键
		/// <summary>
        /// 检测是否存在该主键
        /// </summary>
        /// <param name="int tEMPLATE_ID" 主键列表</param>
        /// <returns>是/否</returns>
		public bool Exists(int tEMPLATE_ID)
		{
			
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@tEMPLATE_ID", SqlDbType.Int)
			};				
			_param[0].Value = tEMPLATE_ID;
			
            string sqlStr="select Count(*) from UR_REPORTTEMPLATE where  TEMPLATE_ID=@tEMPLATE_ID and TEMPLATE_ID=@tEMPLATE_ID";
						
            int a=Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr,_param));
            if(a>0)
            {
                return true;
            }
            else
            {
                return false;
            }
		}

		#endregion

		#region GetModel 根据主键ID,得到数据实体
        /// <summary>
		/// 根据主键ID,得到 ur_reporttemplate 数据实体
		/// </summary>
		/// <param name="int tEMPLATE_ID" 主键列表</param>
		/// <returns>ur_reporttemplate 数据实体</returns>
		public CommonLib.Model.UR_REPORTTEMPLATE GetModel(int tEMPLATE_ID )
		{
			CommonLib.Model.UR_REPORTTEMPLATE _obj=null;
			// 声明参数数组并赋值




			SqlParameter[] _param=
			{
				new SqlParameter("@tEMPLATE_ID", SqlDbType.Int)
			};				
			_param[0].Value = tEMPLATE_ID;
			
			string sqlStr="select * from UR_REPORTTEMPLATE where  TEMPLATE_ID=@tEMPLATE_ID";
			using(SqlDataReader dr=SqlHelper.ExecuteReader(Conn.SqlConnStr,CommandType.Text,sqlStr,_param))
			{
				while(dr.Read())
				{
            		_obj=PopulateUR_REPORTTEMPLATEModelFromDr(dr);
				}
			}
			return _obj;
		}
		#endregion
		
		#region ----根据DataRow,得到 数据实体
		/// <summary>
		/// 得到  ur_reporttemplate 数据实体
		/// </summary>
		/// <param name="row">row</param>
		/// <returns>ur_reporttemplate 数据实体</returns>
		public CommonLib.Model.UR_REPORTTEMPLATE PopulateUR_REPORTTEMPLATEModelFromDr(DataRow row)
		{
			CommonLib.Model.UR_REPORTTEMPLATE Obj = new CommonLib.Model.UR_REPORTTEMPLATE();
			if(row!=null)
			{
				Obj.TEMPLATE_ID = (( row["TEMPLATE_ID"])==DBNull.Value)?0:Convert.ToInt32( row["TEMPLATE_ID"]);
				Obj.REPORTTYPE_ID = (( row["REPORTTYPE_ID"])==DBNull.Value)?0:Convert.ToInt32( row["REPORTTYPE_ID"]);
				Obj.TEMPLATE_NAME =  row["TEMPLATE_NAME"].ToString();
				Obj.FILE_CONTENT =  row["FILE_CONTENT"].ToString();
				Obj.TEMPLATE_FILE =  row["TEMPLATE_FILE"].ToString();
				Obj.TEMPLATE_TYPE = (( row["TEMPLATE_TYPE"])==DBNull.Value)?0:Convert.ToInt32( row["TEMPLATE_TYPE"]);
				Obj.REPLACE_OPTION =  row["REPLACE_OPTION"].ToString();
				Obj.USE_RANGE =  row["USE_RANGE"].ToString();
				Obj.TEMPLATE = (( row["TEMPLATE"])==DBNull.Value)?CommonLib.ComMon.ConvertType.ObjectToBytes(0):CommonLib.ComMon.ConvertType.ObjectToBytes( row["TEMPLATE"]);
				Obj.SUB_SYSTEM = (short) row["SUB_SYSTEM"];
				Obj.CLASS1 =  row["CLASS1"].ToString();
				Obj.CLASS2 =  row["CLASS2"].ToString();
				Obj.CLASS3 =  row["CLASS3"].ToString();
				Obj.REMARK =  row["REMARK"].ToString();
			}
			else
			{
				return null;
			}
			return Obj;
		}
		#endregion
		
		#region ----根据IDataReader,得到 数据实体
        /// <summary>
		/// 得到  ur_reporttemplate 数据实体
		/// </summary>
		/// <param name="dr">dr</param>
		/// <returns>ur_reporttemplate 数据实体</returns>
		public CommonLib.Model.UR_REPORTTEMPLATE PopulateUR_REPORTTEMPLATEModelFromDr(IDataReader dr)
		{
			CommonLib.Model.UR_REPORTTEMPLATE Obj = new CommonLib.Model.UR_REPORTTEMPLATE();
			
				Obj.TEMPLATE_ID = (( dr["TEMPLATE_ID"])==DBNull.Value)?0:Convert.ToInt32( dr["TEMPLATE_ID"]);
				Obj.REPORTTYPE_ID = (( dr["REPORTTYPE_ID"])==DBNull.Value)?0:Convert.ToInt32( dr["REPORTTYPE_ID"]);
				Obj.TEMPLATE_NAME =  dr["TEMPLATE_NAME"].ToString();
				Obj.FILE_CONTENT =  dr["FILE_CONTENT"].ToString();
				Obj.TEMPLATE_FILE =  dr["TEMPLATE_FILE"].ToString();
				Obj.TEMPLATE_TYPE = (( dr["TEMPLATE_TYPE"])==DBNull.Value)?0:Convert.ToInt32( dr["TEMPLATE_TYPE"]);
				Obj.REPLACE_OPTION =  dr["REPLACE_OPTION"].ToString();
				Obj.USE_RANGE =  dr["USE_RANGE"].ToString();
				Obj.TEMPLATE = (( dr["TEMPLATE"])==DBNull.Value)?CommonLib.ComMon.ConvertType.ObjectToBytes(0):CommonLib.ComMon.ConvertType.ObjectToBytes( dr["TEMPLATE"]);
				Obj.SUB_SYSTEM = (short) dr["SUB_SYSTEM"];
				Obj.CLASS1 =  dr["CLASS1"].ToString();
				Obj.CLASS2 =  dr["CLASS2"].ToString();
				Obj.CLASS3 =  dr["CLASS3"].ToString();
				Obj.REMARK =  dr["REMARK"].ToString();
			
			return Obj;
		}
		#endregion
///
		#region GetNewID 通过种子得到唯一ID,对单主键有效单，如果该表为多主键，则返回第一主键
		/// <summary>
        ///  通过种子得到唯一ID,对单主键有效单，如果该表为多主键，则返回第一主键
        /// </summary>
        /// <param name="tEMPLATE_ID">tEMPLATE_ID</param>
        /// <returns>int</returns>
		public int GetNewID()
		{
			return  DBCommon.GetNewIDForTable("UR_REPORTTEMPLATE","UR_REPORTTEMPLATE","");
		}
		#endregion
///
		#region	GetMaxID 得到最大ID	
		/// <summary>
		/// 得到最大ID
		/// </summary>
        /// <param name="tEMPLATE_ID">tEMPLATE_ID</param>
        /// <returns>int</returns>
		public int GetMaxID()
		{
			return  0;
		}
		#endregion
		
		#region	GetList 得到数据表指定字段列表的所有记录，可排序，
		/// <summary>
		/// 得到数据表UR_REPORTTEMPLATE所有记录，可排序




		/// </summary>
        /// <param name="sWhere">条件字符串</param>
        /// <param name="sOder">排序字段</param>
		/// <returns>DataSet</returns>
		public DataSet GetList(string sWhere, string sOder)
		{
			string	sqlStr="select * from "+TableString;
				
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			if (sOder.Length > 0)
				sqlStr += " order by " + sOder;
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion

		#region	GetListFS 得到数据表指定字段列表的所有记录，可排序，加工作流状态字段




		/// <summary>
		/// 得到数据表UR_REPORTTEMPLATE所有记录，可排序，加工作流状态字段




		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
        /// <param name="sWhere">条件字符串</param>
        /// <param name="sOder">排序字段</param>
		/// <returns>DataSet</returns>
		public DataSet GetListFS(string FlowProcessId, string sWhere, string sOder)
		{
			string	sqlStr="select SQL_A.*, isnull(SQL_B.work_state,'未发送') work_state from "+TableString+" left join view_wfInstance_state SQL_B on SQL_a.work_id=SQL_b.work_id";
				
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			if (sOder.Length > 0)
				sqlStr += " order by " + sOder;
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion


		#region GetPageList 根据条件和页号得到某页的记录集,+排序
		/// <summary>
		/// 根据条件和页号得到某页的记录集,+排序
		/// </summary>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="iPageIndex">页号</param>
		/// <param name="sWhere">条件字符串</param>
		/// <param name="sOder">排序字段</param>
        /// <returns>DataSet</returns>
		public DataSet GetPageList(int iPageSize,int iPageIndex, string sWhere, string sOder)
		{
			if (sOder.Length <=0)
				sOder = "TEMPLATE_ID";
				
			string	sqlStr="select * from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, * from "+TableString;
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			sqlStr += ") SQL1 where row between "+ Convert.ToString(iPageSize*(iPageIndex-1)+1) +" and "+Convert.ToString(iPageSize*iPageIndex);
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion		

		#region GetPageListFS 根据条件和页号得到某页的记录集,+排序，加工作流状态字段




		/// <summary>
		/// 根据条件和页号得到某页的记录集,+排序，加工作流状态字段




		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="iPageIndex">页号</param>
		/// <param name="sWhere">条件字符串</param>
		/// <param name="sOder">排序字段</param>
        /// <returns>DataSet</returns>
		public DataSet GetPageListFS(string FlowProcessId, int iPageSize,int iPageIndex, string sWhere, string sOder)
		{
			if (sOder.Length <=0)
				sOder = "TEMPLATE_ID";
				
			string	sqlStr="select * from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, SQL_A.*,isnull(SQL_B.work_state,'未发送') work_state from "+TableString+" left join view_wfInstance_state SQL_B on sql_a.work_id=sql_b.work_id";
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
			sqlStr += ") SQL1 where row between "+ Convert.ToString(iPageSize*(iPageIndex-1)+1) +" and "+Convert.ToString(iPageSize*iPageIndex);
			return SqlHelper.ExecuteDataset(Conn.SqlConnStr,CommandType.Text,sqlStr);
		}
		#endregion		
		
		
		#region GetRecorderRowNum 判断某条记录所在的行号
		/// <summary>
		/// 判断某条记录所在的行号，调用者自己计算页号和行号
		/// </summary>
        /// <param name="sWhere">记录显示的条件</param>
        /// <param name="sOder">排序条件</param>
        /// <param name="iPageSize">每页记录数</param>
		/// <param name="主键列表">主键列表，需定位记录的键值</param>
        /// <returns>int 页码</returns>
		public int GetRecorderRowNum(string sWhere, string sOder, int iPageSize, int tEMPLATE_ID)
		{
			if (sOder.Length <=0)
				sOder = "TEMPLATE_ID";
				
			// 声明参数数组并赋值



			SqlParameter[] _param=
			{
				new SqlParameter("@tEMPLATE_ID", SqlDbType.Int)
			};				
			_param[0].Value = tEMPLATE_ID;
			
			string	sqlStr="select row from (select ROW_NUMBER() OVER(order by "+sOder+" ) as row, tEMPLATE_ID from "+TableString;
			
			if (sWhere.Length > 0)
				sqlStr += " where " + sWhere;
				
			sqlStr = sqlStr + ") SQL1 where  TEMPLATE_ID=@tEMPLATE_ID";
			return Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr,_param));
		}
		#endregion
		
						
		#region GetRecorderCount 得到符合条件记录集的记录条数
		/// <summary>
		/// 得到符合条件记录集的记录条数
		/// </summary>
        /// <param name="FlowProcessId">流程ID</param>
		/// <param name="sWhere">条件字符串</param>
        /// <returns>int 记录数</returns>
		public int GetRecorderCount(string FlowProcessId, string sWhere)
		{
			string sqlStr ="";
			
			if (FlowProcessId.Length > 0)
            	sqlStr="select Count(*) from "+TableString+" left join view_wfInstance_state SQL_B on SQL_a.work_id=SQL_b.work_id";
			else
				sqlStr="select Count(*) from "+TableString;
				
			if (sWhere.Length>0)
				sqlStr += " where " + sWhere;
						
            return Convert.ToInt32(SqlHelper.ExecuteScalar(Conn.SqlConnStr,CommandType.Text,sqlStr));
		}
		#endregion				
		
		#region----------自定义实例化接口函数----------
		#endregion
    }
}
